package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.FugitiveEmissions;
import com.isdepci.project.gasEmission.service.IFugitiveEmissionsService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 逸散性排放Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/fugitiveEmissions/fugitiveEmissions")
public class FugitiveEmissionsController extends BaseController
{
    @Autowired
    private IFugitiveEmissionsService fugitiveEmissionsService;

    /**
     * 查询逸散性排放列表
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:list')")
    @GetMapping("/list")
    public TableDataInfo list(FugitiveEmissions fugitiveEmissions)
    {
        startPage();
        List<FugitiveEmissions> list = fugitiveEmissionsService.selectFugitiveEmissionsList(fugitiveEmissions);
        return getDataTable(list);
    }

    /**
     * 导出逸散性排放列表
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:export')")
    @Log(title = "逸散性排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FugitiveEmissions fugitiveEmissions)
    {
        List<FugitiveEmissions> list = fugitiveEmissionsService.selectFugitiveEmissionsList(fugitiveEmissions);
        ExcelUtil<FugitiveEmissions> util = new ExcelUtil<FugitiveEmissions>(FugitiveEmissions.class);
        return util.exportExcel(list, "fugitiveEmissions");
    }

    /**
     * 获取逸散性排放详细信息
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fugitiveEmissionsService.selectFugitiveEmissionsById(id));
    }

    /**
     * 新增逸散性排放
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:add')")
    @Log(title = "逸散性排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FugitiveEmissions fugitiveEmissions)
    {
        return toAjax(fugitiveEmissionsService.insertFugitiveEmissions(fugitiveEmissions));
    }

    /**
     * 修改逸散性排放
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:edit')")
    @Log(title = "逸散性排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FugitiveEmissions fugitiveEmissions)
    {
        return toAjax(fugitiveEmissionsService.updateFugitiveEmissions(fugitiveEmissions));
    }

    /**
     * 删除逸散性排放
     */
    @PreAuthorize("@ss.hasPermi('fugitiveEmissions:fugitiveEmissions:remove')")
    @Log(title = "逸散性排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fugitiveEmissionsService.deleteFugitiveEmissionsByIds(ids));
    }
}
